package com.juc.reentrantlock;

import java.util.concurrent.locks.ReentrantLock;

public class MService implements Runnable {
	static ReentrantLock lock = new ReentrantLock();
	private static volatile int num = 10;
	private static volatile int count = 10;

	public void m1() {	
		num--;
		m3();
	}

	public void m3() {
		try {
			lock.lock();
			count++;
			System.out.println("m3 state = " + Thread.currentThread().getState());
		} finally {
			lock.unlock();
		}
	}

	@Override
	public void run() {
		try {
			lock.lock();
			m1();
			
			System.out.println(Thread.currentThread().getName() + " num " + num+ "  count:" + count);
		} finally {
			lock.unlock();
		}

	}

}
